#ifndef QQMESSAGEWIDGET_H
#define QQMESSAGEWIDGET_H


#include <QWidget>
#include <QPainterPath>

#include <utils/qqutils.h>

class QQMessageWidget : public QWidget {
    Q_OBJECT
public:
    explicit QQMessageWidget(const QQMessage& msg, bool isSelf = false, QWidget* parent = nullptr);
    QSize sizeHint() const override;
protected:
    void paintEvent(QPaintEvent* event) override;
private:
    void paintBubble(QPainter& painter);
    void paintContent(QPainter& painter);
    void drawAlignedLine(QPainter& painter, const QString& text, int y, int maxWidth);
    void paintTimestamp(QPainter& painter);
    void paintAvatar(QPainter& painter);

    QQMessage m_msg;
    bool m_isSelf;
    QRect m_bubbleRect;
    QRect m_contentRect;
    QRect m_timeRect;
    QRect m_avatarRect;
    static const int BUBBLE_RADIUS = 8;
    static const int AVATAR_SIZE = 40;
    static const int H_MARGIN = 10;
    static const int V_MARGIN = 5;
};

#endif // QQMESSAGEWIDGET_H
